package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.model.Surgery;
import com.rongke.service.SurgeryService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @SurgeryController
 * @手术过程Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/surgery")
@Transactional
public class SurgeryController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SurgeryService surgeryService;

    /**
     * @添加手术过程
     * @param surgery
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addSurgery(@RequestBody Surgery surgery){
        log.debug("添加手术过程");
        surgeryService.insert(surgery);
        return JsonResp.ok(surgery);
    }

    /**
     * @修改手术过程
     * @param surgery
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateSurgery(@RequestBody Surgery surgery){
        log.debug("修改手术过程");
        surgeryService.updateById(surgery);
        return JsonResp.ok(surgery);
    }

    /**
     * @根据id查找手术过程
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectSurgery(Long id){
        log.debug("查找手术过程");
        Surgery surgery = surgeryService.selectById(id);
        return JsonResp.ok(surgery);
    }



}
